package review.chapter03;

/**
 * Enjoy programming!!!
 * Time: 2021/12/22 -  9:37
 */
public class Test {
    public static void main(String[] args) {
        CPU cpu = new CPU();
        cpu.setSpeed(2200);

        HardDisk disk = new HardDisk();
        disk.setAmount(200);

        PC pc = new PC();
        pc.setCPU(cpu);
        pc.setHardDisk(disk);
        pc.show();
    }
}

class PC {
    private CPU cpu;
    private HardDisk HD;

    public void setCPU(CPU c) {
        this.cpu = c;
    }

    public void setHardDisk(HardDisk h) {
        this.HD = h;
    }

    public void show() {
        System.out.printf("CPU的速度是：%d\nHD的容量是：%d\n", cpu.getSpeed(), HD.getAmount());
    }
}

class CPU {
    private int speed;

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }
}

class HardDisk {
    private int amount;

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }
}
